package com.yami.shop.controller;

import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.dto.group.ChannelDTO;
import com.yami.shop.dto.group.GroupChannelDTO;
import com.yami.shop.service.impl.RongYunChannelServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 超级群聊的频道管理
 */

@RestController
@RequestMapping("/p/im/ultraGroup/channel")
@Schema(description = "app-超级群聊的频道管理")
@AllArgsConstructor
public class MeltCloudChannelController {
    
    private final RongYunChannelServiceImpl channelService;

    @PostMapping("/create")
    @Operation(summary =  "创建频道")
    public ServerResponseEntity create(@RequestBody @Valid ChannelDTO channelDTO)  throws Exception {
        return channelService.create(channelDTO);
    }
    
    @GetMapping("/delete")
    @Operation(summary =  "删除频道")
    public ServerResponseEntity delete(@RequestParam Long id)  throws Exception {
        return channelService.delete(id);
    }
    
    @GetMapping("/byGroupId")
    @Operation(summary =  "获取超级群聊的频道列表")
    public ServerResponseEntity getChannelByGroup(@RequestParam Long groupId) throws Exception {
        return channelService.getChannelListByGroupId(groupId);
    }


    @PostMapping("/notDisturb")
    @Operation(summary =  "免打扰设置")
    public ServerResponseEntity notDisturb(@RequestBody @Valid GroupChannelDTO param)  throws Exception {
        return channelService.setNoDisturb(param);
    }
    
    @GetMapping("/getNotDisturb")
    @Operation(summary =  "免打扰配置查询")
    public ServerResponseEntity getNotDisturb(@RequestParam Long groupId, @RequestParam(required = false) String channelId)  throws Exception {
        return channelService.getNoDisturb(groupId, channelId);
    }


    @PostMapping("/type_change")
    @Operation(summary =  "变更频道类型")
    public ServerResponseEntity channelTypeChange(@RequestBody ChannelDTO param) throws Exception {
        return channelService.channelTypeChange(param);
    }
    
    @PostMapping("/private_users_add")
    @Operation(summary =  "添加私有频道成员")
    public ServerResponseEntity addPrivateUsers(@RequestBody ChannelDTO param) throws Exception {
        return channelService.addPrivateUsers(param);
    }
    
    @PostMapping("/private_users_del")
    @Operation(summary =  "删除私有频道成员")
    public ServerResponseEntity delPrivateUsers(@RequestBody ChannelDTO param) throws Exception {
        return channelService.delPrivateUsers(param);
    }
    
    @PostMapping("/quit")
    @Operation(summary =  "退出频道")
    public ServerResponseEntity quitChannel(@RequestBody ChannelDTO param) throws Exception {
        return channelService.quitChannel(param);
    }
    
    @PostMapping("/transfer")
    @Operation(summary =  "频道转交")
    public ServerResponseEntity transferChannel(@RequestBody ChannelDTO param) {
        return channelService.transferChannel(param);
    }
    
    @GetMapping("/private_users")
    @Operation(summary =  "私有频道成员列表")
    public ServerResponseEntity getPrivateUsers(@RequestParam Long groupId, @RequestParam String channelId, @RequestParam(required = false) String currentUserId) {
        return channelService.getPrivateUsers(groupId, channelId, currentUserId);
    }
    
    @GetMapping("/getByUserId")
    @Operation(summary =  "用户所属的私有频道")
    public ServerResponseEntity getChannelList(@RequestParam Long groupId, @RequestParam String userId) {
        return channelService.getChannelList(groupId, userId);
    }
    
    
    
    
    
    
}
